Simple Edit Control

Description

To create an edit control (also called a "text box") on a dialog box, use the '[' and ']' delimiters. The syntax for a text object is:

[variable_name]

For example, the following script creates a simple dialog that prompts a user for a filename. (In fact, this example is so simple, that the simpler UI_GET_TEXT()command would suffice!).

result=ui_dlg_box("Title",<<%dlg%
Filename: [filename];

%dlg% )

This script creates this dialog:

images/XD_Simple_Edit_Control.gif

Edit controls set (and display) the values in variables. So, in the above script, the value that the user enters into the text box is stored in the variable called "filename". For example, if the user types "c:\autoexec.bat" into the text box, the variable, "filename" will be set to the value "c:\autoexec.bat".

Setting the Size of an Edit Control

The text box command takes an optional size parameter. You can increase the size of the text box by specifying a size in characters before the variable name. The size specifies the number of characters to allow in the variables, and also the display size of the text box. For example:

result=ui_dlg_box("Title",<<%dlg%
Filename: [32filename];
%dlg% )

This script creates this dialog:

images/XD_Size_of_Edit_Control.gif

In the above example, the edit field is limited to 32 characters, and the width of the field is set to be 32 characters wide (so the user will not encounter horizontal scrolling as he enters text into the text box). If you want to set a higher limit on the size of the variable, but set the size of text box to a smaller value, you can specify the width of the text box separately from the size of the variable by specifying the text box size after the variable size, separated by a period. For example, variable_size.text_box_size. The command [32.20filename] displays a text box that is 20 characters wide. The text box will accept up to 32 characters. If the user enters more than 20 characters, the text will scroll horizontally. The following script sets the size of the text box to 32 characters, but allows the user to enter up to 128 characters for the filename:

result=ui_dlg_box("Title",<<%dlg%
Filename: [128.32filename];

%dlg% )

This dialog looks the same as the previous dialog. You can omit the leading digit (specifying the variable_size ). This indicates that there is no limit to the number of characters that the user can enter into the text box. For example:

result=ui_dlg_box("Title",<<%dlg%
Filename: [.32filename];

%dlg% )

Again, this looks the same as the previous two examples.

Limitations

Desktop applications only

See Also